package com.csguider.auth;

import com.csguider.auth.mapper.SysRoleMapper;
import com.csguider.model.system.SysRole;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Arrays;
import java.util.List;

/**
 * @Author <a href="https://github.com/wl2o2o">程序员CSGUIDER</a>
 * @From <a href="https://wl2o2o.github.io">CSGUIDER博客</a>
 * @CreateTime 2024/4/27
 */

@SpringBootTest
public class MpTestDemo {

    @Autowired
    private SysRoleMapper sysRoleMapper;

    // 添加
    @Test
    public void add() {
        SysRole sysRole = new SysRole();
        sysRole.setRoleName("csguider");
        int rows = sysRoleMapper.insert(sysRole);
        System.out.println(rows);
        System.out.println(sysRoleMapper.selectList(null));
    }

    // 删除
    @Test
    public void delete() {
        int rows = sysRoleMapper.deleteById(8);
        System.out.println(rows);
        System.out.println(sysRoleMapper.selectList(null));
    }

    // 批量删除
    @Test
    public void deleteBatchIds() {
        int rows = sysRoleMapper.deleteBatchIds(Arrays.asList(1, 2));
        System.out.println(rows);
        System.out.println(sysRoleMapper.selectList(null));
    }

    // 修改
    @Test
    public void update() {
        SysRole sysRole = new SysRole();
        sysRole.setId(8L);
        sysRole.setRoleName("csguider");
        sysRole.setIsDeleted(0);
        int rows = sysRoleMapper.updateById(sysRole);
        System.out.println(rows);
        System.out.println(sysRoleMapper.selectList(null));
    }

    // 查询
    @Test
    public void getAll() {
        List<SysRole> sysRoleMappers = sysRoleMapper.selectList(null);
        System.out.println(sysRoleMappers);

    }

}
